import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:myflutterproject/basematerialwidgetsdemo.dart';

class AbsorbPointerDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => AbsorbPointerState();
}

class AbsorbPointerState extends State<AbsorbPointerDemo> {
  String text = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('AbsorbPointerState'),
        centerTitle: true,
      ),
      body: Center(
        child: Stack(
          children: [
            Container(
              width: 200,
              height: 200,
              child: RaisedButton(
                color: Colors.red,
                onPressed: () {
                  setState(() {
                    text = '点击red';
                  });
                },
              ),
            ),
            //消费掉点击事件，下层也收不到，不会做出相应
            AbsorbPointer(
              //true的时候 禁止点击  false允许点击
                absorbing: true,
                child: Container(
                  width: 100,
                  height: 100,
                  child: RaisedButton(
                    color: Colors.blue,
                    onPressed: () {
                      setState(() {
                        text = '点击blue';
                      });
                    },
                  ),
                ), 
            ),
            TextWidget(text)
          ],
        ),
      ),
    );
  }
}
